package agent;
import oracle.Oracle;

/**
 * This class is the representation of a tile in the world as the Agent sees it.
 * 
 * @author adam
 */
public class AgentTile
{
	/** True if this state is a terminal state */
	public boolean isTerminalState;
	/** The value of this tile, between -10 and 10 */
	public double reward;
	/** True if this tile is a wall */
	public boolean isWall;
	/** Becomes true when the user has visited this state */
	public boolean isVisited;
	/** The row position of this tile */
	public int row;
	/** The column position of this tile */
	public int column;
	/** Which run in the round this tile was explored */
	public int runSeen;
	/** The number of turns remaining when this tile was explored */
	public int moveCountWhenExplored;  
	
	public AgentTile(int row, int col, double reward){
		this.isTerminalState = false;
		this.isWall = false;
		this.isVisited = false;
		this.row = row;
		this.column = col;
		this.reward = reward;
	}
	
	/**
	 * Performs a deep copy of this tile
	 * @return a copy of this tile
	 */
	public AgentTile deepCopy() {
		AgentTile newTile = new AgentTile(this.row, this.column, this.reward);
		newTile.isTerminalState = this.isTerminalState;
		newTile.isWall = this.isWall;
		newTile.isVisited = this.isVisited;
		return newTile;
	}
	
	/**
	 * Returns true if this tile is reachable from other tile
	 * using Manhattan distance assuming we can go through walls
	 * @param otherTile A tile representing the other (row, column)
	 * @param maxManDistance The maximum line of sight in manhattan metric
	 * @return True if this tile can be reached
	 */
	public boolean isReachableFrom(AgentTile otherTile){
		if(Math.abs(this.row - otherTile.row) + Math.abs(this.column - otherTile.column) <= Oracle.getMaxSightRange())
			return true;
		return false;
	}
	
	public String toString(){
		String s = "Tile is ("+ row + ","+column + ") and reward :: " + reward + " and visited :: " + isVisited;
		return s;
	}

}